﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smartec.Accounts.Camel.AMS.Model.Entities;
using Smartec.Accounts.Camel.AMS.Model.Repository;

namespace Smartec.Accounts.Camel.AMS.Model.Facades
{
   public static class NewsFacade
    {
       public static void AddNews(News news)
       {
           NewsRepository.AddNews(news);
          
       }

       public static List<News> GetAllNews()
       {
           return NewsRepository.All();
       }

       public static News GetNewsById(int id)
       {
           return NewsRepository.All().FirstOrDefault(t => t.ID == id);
       }
       public static void Save()
       {
           NewsRepository.Save();
       }
       public static void UpdateNews(News news)
       {
           var _news = GetNewsById(news.ID);
           _news.Name = news.Name;
           _news.ShortDescription = news.ShortDescription;
           _news.FullDescription = news.FullDescription;
       }

       public static void DeleteNewsById(int id)
       {
           NewsRepository.DeleteNewsById(id);
       }
    }
}
